package algorithm;

public class OneNumber {
    // 1011
    public static int hammingWeight(int n) {
        int count = 0;
        for (int i = 0; i < 32; i++) {
             if ((n & (1 << i)) != 0) {
                 count++;
             }
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println(hammingWeight(0));
        System.out.println(hammingWeight(1));
        System.out.println(hammingWeight(2));
        System.out.println(hammingWeight(3));
    }
}
